package cc.comac.mom.service.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.QualityPlanToDoService;
import cc.comac.mom.bean.QualityPlanToDo;
import cc.comac.mom.bean.base.LimitPageBean;
import cc.comac.mom.datahandlers.entity.QualityPlanToDoDataHandler;
import cc.comac.mom.entity.QualityPlanToDoEntity;
import cc.comac.mom.util.ResultBean;

@RestController
@Service
public class QualityPlanToDoServiceImpl  implements QualityPlanToDoService{
	@Autowired
	private QualityPlanToDoDataHandler  qualityPlanToDoDataHandler;

	@Override
	public ResultBean insert(@RequestBody QualityPlanToDo obj) {
		// TODO Auto-generated method stub
		return qualityPlanToDoDataHandler.insert(obj);
	}

	@Override
	public ResultBean planConfirmBatch(@RequestBody List<Long> ids) {
		// TODO Auto-generated method stub
		return qualityPlanToDoDataHandler.planConfirmBatch(ids);
	}

	@Override
	public ResultBean selectByCondition(@RequestBody QualityPlanToDo obj) {
		ResultBean resultBean = new ResultBean(true);
		LimitPageBean<QualityPlanToDoEntity> limitPageBean = qualityPlanToDoDataHandler.selectByCondition(obj);
		resultBean.setObject(limitPageBean);
		return resultBean;
	}

	@Override
	public ResultBean getUnTreatedByPartNoAndToDoStatus(@RequestParam(value="partNo")String partNo, @RequestParam(value="toDoType")int toDoType) {
		ResultBean resultBean = new ResultBean(true);
		List<QualityPlanToDo> list = qualityPlanToDoDataHandler.getUnTreatedByPartNoAndToDoStatus(partNo, Arrays.asList(toDoType),null);
		resultBean.setObject(list);
		return resultBean;
	}

	
}
